package com.vcs.frm.service.common;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.vcs.frm.dao.common.CommonDao;
import com.vcs.frm.domain.Job;
import com.vcs.frm.domain.User;

@Service
public class CommonServiceImpl implements CommonService{

	@Autowired
	CommonDao  commonDao;
	
	public void setCommonDao(CommonDao commonDao) {
		this.commonDao = commonDao;
	}
	
	@Override
	@Transactional
	public User getUserByUsername(String username) {

		User user = commonDao.getUserByUsername(username);

		return user;
	}

	@Override
	public List<Job> getRecentJobs(int size) {
		List<Job> recentJobs = commonDao.getRecentJobs(size);
		return recentJobs;
	}

	@Override
	public Job getJobByJobId(Long jobId){
		
		Job job = commonDao.getJobByJobId(jobId);
		return job;
	}

	@Override
	public Long saveUser(User user) {
		Long userId = commonDao.saveUser(user);
		return userId;
	}

	@Override
	public void updateUser(User user) {
		commonDao.updateUser(user);
	}

	@Override
	public User getUserById(Long userId) {
		User user = commonDao.getUserById(userId);
		return user;
	}
}
